from concurrent.futures import ThreadPoolExecutor


def some_function(arg):
    if arg == 3:
        raise ValueError("Invalid argument")
    return arg * 2


with ThreadPoolExecutor() as executor:
    futures = [executor.submit(some_function, i) for i in range(5)]
    for future in futures:
        try:
            result = future.result()
            print(result)
        except Exception as e:
            print(f"Exception: {e}")
"""
异常处理：Future 对象可以捕获任务中抛出的异常。通过检查 future.exception() 方法，可以获得异常信息。
"""
